import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCykPCrvqhgG9vR7pW29xObvHv6aD1A+3hiwfkEkkT1PsI0VL0HgZo3H6u0wqzar7k09yekMZivFxXLMmSOhhh6/P10FGVEoML4k8sEQs/T7VV5ood162jEXkk5GrEoqHO2Cx5bmTB2KqW6D5yhrjqdSv7GT9/fEBlfsYVVvgjniQIDAQAB'

const privateKey = ''

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

